/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fileUtils;

import java.io.File;
import java.io.IOException;

/**
 * 文件清理
 * @author yxd
 */
public class FileCleaner {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        File directory = new File("D:\\project\\waijing\\yxd\\src");
        delete(directory,".svn");

    }

    /**
     * 删除某个目录下的名为suffix后缀的文件
     * @param directory 指定的目录
     * @param suffix 后缀名
     */
    private static void delete(File directory,String suffix){
        File[] list = directory.listFiles();
        for (File file : list) {
            if(!file.isDirectory()){
                if(file.getName().endsWith(suffix)){
                    file.delete();
                }
            }else{
                delete(file,suffix);
            }
        }
    }
}
